package cn.iocoder.yudao.module.question.dal.mysql.question;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.question.dal.dataobject.question.QuestionDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.question.controller.admin.question.vo.*;

/**
 * 试题信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface QuestionMapper extends BaseMapperX<QuestionDO> {

    default PageResult<QuestionDO> selectPage(QuestionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<QuestionDO>()
                .eqIfPresent(QuestionDO::getBankId, reqVO.getBankId())
                .eqIfPresent(QuestionDO::getParentQuestionId, reqVO.getParentQuestionId())
                .eqIfPresent(QuestionDO::getQuestionContent, reqVO.getQuestionContent())
                .eqIfPresent(QuestionDO::getQuestionType, reqVO.getQuestionType())
                .eqIfPresent(QuestionDO::getQuestionLevel, reqVO.getQuestionLevel())
                .eqIfPresent(QuestionDO::getStandardAnalysis, reqVO.getStandardAnalysis())
                .eqIfPresent(QuestionDO::getItemOrder, reqVO.getItemOrder())
                .orderByDesc(QuestionDO::getId));
    }

    default List<QuestionDO> selectList(QuestionExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<QuestionDO>()
                .eqIfPresent(QuestionDO::getBankId, reqVO.getBankId())
                .eqIfPresent(QuestionDO::getParentQuestionId, reqVO.getParentQuestionId())
                .eqIfPresent(QuestionDO::getQuestionContent, reqVO.getQuestionContent())
                .eqIfPresent(QuestionDO::getQuestionType, reqVO.getQuestionType())
                .eqIfPresent(QuestionDO::getQuestionLevel, reqVO.getQuestionLevel())
                .eqIfPresent(QuestionDO::getStandardAnalysis, reqVO.getStandardAnalysis())
                .eqIfPresent(QuestionDO::getItemOrder, reqVO.getItemOrder())
                .orderByDesc(QuestionDO::getId));
    }

}
